package com.dd.cloud.user.res.pres;

import com.dd.cloud.common.annotate.FileSuffix;
import com.dd.cloud.common.constants.PharConstants;
import com.dd.cloud.common.utils.AddrUtils;
import com.dd.cloud.user.entity.doctor.PatientMedCard;
import com.dd.cloud.user.entity.order.OrderPay;
import com.dd.cloud.user.entity.pres.*;
import com.dd.cloud.user.res.aicms.AicmsDiagnosticResultDetail;
import com.dd.cloud.user.res.doctor.PatientMedCardAddrListH5Res;
import com.dd.cloud.user.res.order.OrderFlowListRes;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 处方表
 * </p>
 *
 * @author czg
 * @since 2022-04-27
 */
@Data
public class PresPrescriptionDetailRes {
    /**
     * 处方编码 患者处方表
     */
    private String tencode;

    /**
     * 药房id
     */
    private Integer pharmId;

    /**
     * 药房名称
     */
    private String pharmacyName;

    /**
     * 药房标识
     */
    private Integer flag;

    /**
     * 诊断id
     */
    private Integer diagnosticId;

    /**
     * 在线问诊id
     */
    private Integer consultId;

    /**
     * 医生id
     */
    private Integer doctorId;

    /**
     * 医生名称
     */
    private String doctorName;

    /**
     * 审核医生id
     */
    private Integer reviewDoctorId;

    /**
     * 审核医生名称
     */
    private String reviewDoctorName;

    /**
     * 机构名称
     */
    private String mechanName;

    /**
     * 就诊卡id
     */
    private String medId;

    /**
     * 姓名
     */
    private String name;

    /**
     * 年龄
     */
    private String age;

    /**
     * 性别
     */
    private String sex;

    /**
     * 婚姻
     */
    private String maritalStatus;

    /**
     * 是否怀孕 0否 1是
     */
    private Integer pregnant;

    /**
     * 手机号
     */
    private String phoneNum;

    /**
     * 联系地址
     */
    private String contactAddr;

    /**
     * 科室名
     */
    private String departmentName;

    /**
     * 疾病名
     */
    private String diseaseName;

    /**
     * 症状
     */
    private String symptomList;

    /**
     * 民族
     */
    private String ethnicity;

    /**
     * 处方状态
     */
    private Integer status;

    /**
     * 每日剂数
     */
    private Integer dayDose;

    /**
     * 总剂数
     */
    private Integer allDose;

    /**
     * 创建时间
     */
    private LocalDateTime createDate;

    /**
     * 更新时间
     */
    private LocalDateTime updateDate;

    /**
     * 备注
     */
    private String remark;

    /**
     * 每剂次数
     */
    private Integer doseNum;

    /**
     * 每剂药材量 默认180 单位ml
     */
    private String drugDose;

    /**
     * 医嘱
     */
    private String advice;

    /**
     * 疗期医嘱
     */
    private String treatAdvice;

    /**
     * 用法补充
     */
    private String drugUsage;

    /**
     * 是否ai开方
     */
    private Integer isAiPres;

    /**
     * 快递单号
     */
    private String expressno;

    /**
     * 快递公司
     */
    private String expresscompany;

    /**
     * 诊断结果
     */
    private AicmsDiagnosticResultDetail result;

    /**
     * 诊断结果
     */
    private PatientMedCard patientMedCard;

    /**
     * 药品列表
     */
    private List<PresPretrialDrugs> drugs;

    /**
     * 宏济堂
     */
    private PresHjtDetail presHjtDetail;

    /**
     * 大参林
     */
    private PresDslDetail presDslDetail;

    /**
     * 康美
     */
    private PresKmDetail presKmDetail;

    /**
     * 其他药房
     */
    private PresOtherDetail presOtherDetail;

    /**
     * 一方制药
     */
    private PresYfDetail presYfDetail;

    /**
     * 华润三九
     */
    private PresHrDetail presHrDetail;

    /**
     * 订单
     */
    private OrderPay orderPay;

    /**
     * 流水列表
     */
    private List<OrderFlowListRes> flowListRes;

    /**
     * 药品金额 分单位
     */
    private Integer money;

    /**
     * 折扣药品金额 分单位
     */
    private Integer discountMoney;

    /**
     * 诊疗费 必填
     */
    private Integer consultationFee;

    /**
     * 服务费 必填
     */
    private Integer serviceFee;

    /**
     * 物流费 必填
     */
    private Integer expensesFee;

    /**
     * 代煎费 必填
     */
    private Integer fryingFee;

    /**
     * 签名
     */
    @FileSuffix
    private String sign;

    /**
     * 二次签名
     */
    @FileSuffix
    private String confirmSign;

    /**
     * 处方pdf
     */
    @FileSuffix
    private String pdfUrl;

    /**
     * 收货人
     */
    private String receiver;

    /**
     * 收货人手机号
     */
    private String receiverPhone;

    /**
     * 收货地址
     */
    private String addr;

    /**
     * 出库时间
     */
    private String outboundDate;

    /**
     * 收货时间
     */
    private String receivingTime;

    /**
     * 处方订单地址信息
     */
    private PatientMedCardAddrListH5Res addrRes;

    /**
     * 处方流转信息处理记录
     */
    private List<PresHandleRecordRes> presHandleList;

    /**
     * 是否有折扣
     */
    private Boolean isCount;

    /**
     * 类型
     */
    private Integer presType;


    /**
     * 预计出粉量
     */
    private String outPut;

    /**
     * 使用天数
     */
    private String useDay;

    /**
     * 膏方/蜂蜜费用 单位分
     */
    private Integer otherFee;

    /**
     * 辅料列表
     */
    private List<PresSaveMaterial> presCreateCreamFormulaReqs;

    /**
     * 目数
     */
    private String num;

    /**
     * 是否显示到付
     */
    private Integer deliveryIsDisplay;

    /**
     * 起订量
     */
    private String minWeight;

    /**
     * 签名-审核二次医生
     */
    @FileSuffix
    private String reviewConfirmSign;

    /**
     * 签名
     */
    @FileSuffix
    private String reviewSign;

    /**
     * 拒绝原因
     */
    private String rejectReason;

    /**
     * 地址
     */
    private String address;

    /**
     * 诊断编号
     */
    private String diagnosticName;

    /**
     * 编码
     */
    private String zyCode;

    /**
     * 名
     */
    private String zyName;

    /**
     * 过敏史
     */
    private String drugAllergyHistory;

    /**
     * 来源类型
     */
    private Integer sourceType;

    /**
     * 是否显示药品 0否 1是
     */
    private Integer drugShow;

    /**
     * 是否显示药品用量 0否 1是
     */
    private Integer drugDoseShow;

    /**
     * 文字状态
     */
    private String statusText;

    /**
     * 用药方式
     */
    private String useDrugWay;

    /**
     * 药师标志
     */
    private Integer pharmacistsFlag;

    /**
     * 线下疾病
     */
    private String offlineDisease;

    /**
     * 是否代煎 0.否 1.是
     */
    private Integer isFrying;

    /**
     * 初始化地址信息
     */
    public void initAddrRes() {
        PatientMedCardAddrListH5Res addr = new PatientMedCardAddrListH5Res();
        try {
            if (this.flag == PharConstants.Flag.HJT) {
                AddrUtils.AddrEntity addrEntity = AddrUtils.getAddrEntity(this.presHjtDetail.getAddress());
                if (addrEntity.getFlag() == 1) {
                    addr.setProvince(addrEntity.getProvince());
                    addr.setCity(addrEntity.getCity());
                    addr.setDistrict(addrEntity.getDistrict());
                    addr.setAddr(addrEntity.getAddr());
                }
                this.receiver = this.presHjtDetail.getDtbcompany();
                this.receiverPhone = this.presHjtDetail.getDtbphone();
                this.addr = this.presHjtDetail.getDtbaddress();
            } else if (this.flag == PharConstants.Flag.DSL) {
                addr.setProvince(this.presDslDetail.getConsigneeProvince());
                addr.setCity(this.presDslDetail.getConsigneeCity());
                addr.setDistrict(this.presDslDetail.getConsigneeRegion());
                addr.setAddr(this.presDslDetail.getConsigneeDetailAddress());
                this.receiver = this.presDslDetail.getConsigneeName();
                this.receiverPhone = this.presDslDetail.getConsigneePhone();
                this.addr = this.presDslDetail.getConsigneeProvince() + this.presDslDetail.getConsigneeCity() + this.presDslDetail.getConsigneeRegion() + this.presDslDetail.getConsigneeDetailAddress();
            } else if (this.flag == PharConstants.Flag.KM) {
                AddrUtils.AddrEntity addrEntity = AddrUtils.getAddrEntity(this.presKmDetail.getAddrStr().replace(",", ""));
                if (addrEntity.getFlag() == 1) {
                    addr.setProvince(addrEntity.getProvince());
                    addr.setCity(addrEntity.getCity());
                    addr.setDistrict(addrEntity.getDistrict());
                    addr.setAddr(addrEntity.getAddr());
                }
                this.receiver = this.presKmDetail.getConsignee();
                this.receiverPhone = this.presKmDetail.getConTel();
                this.addr = this.presKmDetail.getAddrStr().replace(",", "");
            } else if (this.flag == PharConstants.Flag.YF) {
                AddrUtils.AddrEntity addrEntity = AddrUtils.getAddrEntity(this.presYfDetail.getBorrowerCity().replace(",", ""));
                if (addrEntity.getFlag() == 1) {
                    addr.setProvince(addrEntity.getProvince());
                    addr.setCity(addrEntity.getCity());
                    addr.setDistrict(addrEntity.getDistrict());
                    addr.setAddr(this.presYfDetail.getBorrowerAddress());
                }
                this.receiver = this.presYfDetail.getBorrowerName();
                this.receiverPhone = this.presYfDetail.getBorrowerPhone();
                this.addr = this.presYfDetail.getBorrowerCity().replace(",", "") + this.presYfDetail.getBorrowerAddress();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.addrRes = addr;
    }
}
